/*
 * @Description: 
 * @Author: houcw
 * @Date: 2024-01-25 14:47:51
 * @LastEditTime: 2024-01-25 14:48:01
 * @LastEditors: houcw
 * @Reference: 
 */
//1, 引入mongoose
var mongoose = require("mongoose")
//导入 配置文件
const {DBHOST, DBPORT, DBNAME} = require('../config/config.js');
mongoose.set("strictQuery", true);
//2，连接MongoDB数据库
mongoose.connect(`mongodb://${DBHOST}:${DBPORT}/${DBNAME}`, { useNewUrlParser: true });
mongoose.connection.on('connected', function () {
  console.log('MongoDB connected success.');
});

mongoose.connection.on('error', function () {
  console.log('MongoDB connected fail.');
});

mongoose.connection.on('disconnected', function () {
  console.log('MongoDB connected disconnected.');
});
module.exports = mongoose;
